#include <stdio.h>
#include <string.h>

char seperate = '$';
void CreateData(char data[][256], int *count);

void InitializeTestCase(char inputs[][256],char outputs[][256], int *count)
{
    char data[256][256];
    CreateData(data,count);

    int i;
    for (i=0; i<*count; i++)
    {
        char* ptr;
        int index, len;
        ptr = strchr(data[i], seperate);
        index = ptr - data[i];
        len = strlen(data[i])-index;
        strncpy(inputs[i], data[i], index);
        inputs[i][index] = '\0';
        strncpy(outputs[i], data[i] + index + 1, len);
    }
}

void RunAllTestCase(void (*testConvertFunc)(char input[], char output[]), int writeAllPass)
{
    int count;
    char inputs[256][256];
    char expectedOutputs[256][256];

    InitializeTestCase(inputs,expectedOutputs,&count);

    char actualOutput[256];
    int i;
    for (i=0; i<count; i++)
    {
        testConvertFunc(inputs[i], actualOutput);

        char result[10];
        if(strcmp(expectedOutputs[i],actualOutput)==0)
        {
            //2 strings are equal
            strcpy(result,"Pass:");
        }
        else
        {
            //2 strings are not equal
            strcpy(result,"Failure:");
        }

        if(strcmp(result,"Failure:")==0 || (writeAllPass==1 && strcmp(result,"Pass:")==0))
        {
            printf("%s in test case %d\n\tInput: %s\n\tExpected: %s\n\tActual: %s\n", result, i+1,inputs[i], expectedOutputs[i],actualOutput);
        }
    }
}

//////////////////////
//This function will change by your function
void SpellNumber(char input[], char output[])
{
    strcpy(output,"mot");
}
//////////////////////

int main()
{
    //RunAllTestCase(SpellNumber,0);
    RunAllTestCase(SpellNumber,1);
}

//Create data
void CreateData(char data[][256], int *count)
{
    strcpy(data[0], "some string$Your input is not natural number.");
    strcpy(data[1], "121235264789456321451$Your input is over 20 characters.");
    strcpy(data[2], "0$khong");
    strcpy(data[3], "1$mot");
    strcpy(data[4], "2$hai");
    strcpy(data[5], "3$ba");
    strcpy(data[6], "4$bon");
    strcpy(data[7], "5$nam");
    strcpy(data[8], "6$sau");
    strcpy(data[9], "7$bay");
    strcpy(data[10], "8$tam");
    strcpy(data[11], "9$chin");
    strcpy(data[12], "10$muoi");
    strcpy(data[13], "11$muoi mot");
    strcpy(data[14], "20$hai muoi");
    strcpy(data[15], "21$hai muoi mot");
    strcpy(data[16], "22$hai muoi hai");
    strcpy(data[17], "25$hai muoi lam");
    strcpy(data[18], "30$ba muoi");
    strcpy(data[19], "31$ba muoi mot");
    strcpy(data[20], "32$ba muoi hai");
    strcpy(data[21], "35$ba muoi lam");
    strcpy(data[22], "40$bon muoi");
    strcpy(data[23], "41$bon muoi mot");
    strcpy(data[24], "44$bon muoi tu");
    strcpy(data[25], "45$bon muoi lam");

    strcpy(data[26], "100$mot tram");
    strcpy(data[27], "101$mot tram linh mot");
    strcpy(data[28], "102$mot tram linh hai");
    strcpy(data[29], "104$mot tram linh tu");
    strcpy(data[30], "110$mot tram muoi");
    strcpy(data[31], "111$mot tram muoi mot");
    strcpy(data[32], "112$mot tram muoi hai");
    strcpy(data[33], "114$mot tram muoi bon");
    strcpy(data[34], "120$mot tram hai muoi");
    strcpy(data[35], "121$mot tram hai muoi mot");
    strcpy(data[36], "124$mot tram hai muoi tu");
    strcpy(data[37], "130$mot tram ba muoi");
    strcpy(data[38], "131$mot tram ba muoi mot");
    strcpy(data[39], "200$hai tram");
    strcpy(data[40], "300$ba tram");

    strcpy(data[41], "1000$mot nghin");
    strcpy(data[42], "1001$mot nghin linh mot");
    strcpy(data[43], "1004$mot nghin linh tu");
    strcpy(data[44], "1010$mot nghin khong tram muoi");
    strcpy(data[45], "1014$mot nghin khong tram muoi bon");
    strcpy(data[46], "1025$mot nghin khong tram hai muoi lam");
    strcpy(data[47], "1100$mot nghin mot tram");
    strcpy(data[48], "1101$mot nghin mot tram linh mot");
    strcpy(data[49], "1104$mot nghin mot tram linh tu");
    strcpy(data[50], "1200$mot nghin hai tram");
    strcpy(data[51], "1234$mot nghin hai tram ba muoi tu");
    strcpy(data[52], "2000$hai nghin");

    strcpy(data[53], "-123$Your input is not natural number.");
    strcpy(data[54], "1.23$Your input is not natural number.");
    strcpy(data[55], "12,3$Your input is not natural number.");

    strcpy(data[56], "10000$muoi nghin");
    strcpy(data[57], "20000$hai muoi nghin");
    strcpy(data[58], "12345$muoi hai nghin ba tram bon muoi lam");
    strcpy(data[59], "10001$muoi nghin khong tram linh mot");
    strcpy(data[60], "10101$muoi nghin mot tram linh mot");
    strcpy(data[61], "11111$muoi mot nghin mot tram muoi mot");

    strcpy(data[62], "100000$mot tram nghin");
    strcpy(data[63], "654321$sau tram nam muoi tu nghin ba tram hai muoi mot");

    strcpy(data[64], "1000000$mot trieu");
    strcpy(data[65], "7654321$bay trieu sau tram nam muoi tu nghin ba tram hai muoi mot");

    strcpy(data[66], "10000000$muoi trieu");
    strcpy(data[67], "87654321$tam muoi bay trieu sau tram nam muoi tu nghin ba tram hai muoi mot");

    strcpy(data[68], "100000000$mot tram trieu");
    strcpy(data[69], "987654321$chin tram tam muoi bay trieu sau tram nam muoi tu nghin ba tram hai muoi mot");

    strcpy(data[70], "1000000000$mot ty");
    strcpy(data[71], "9876543210$chin ty tam tram bay muoi sau trieu nam tram bon muoi ba nghin hai tram muoi");
    strcpy(data[72], "5076003010$nam ty khong tram bay muoi sau trieu khong tram linh ba nghin khong tram muoi");
    *count = 73;
}
